<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>登录页面</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<script src="/js/plugins/jquery-form/jquery.form.js"></script>
	<script src="/js/plugins/dialog2/dialog.min.js"></script>
	<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" >
	<link rel="stylesheet" href="/css/reset.css" >
	<link rel="stylesheet" href="/css/login.css" >
	<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">

	<script>
        $(function () {
            $('.checkhead').blur(function () {
                var email = $('.checkhead').val();
                $.get("/usersCheck",{email:email},function (data) {
                    if(data!=null){
                        $('.imgHead').attr("src",data.coverImgUrl);
					}
                })
            });

            $('#loginForm').ajaxForm(function (data) {
                if(data.success){
                    sessionStorage.setItem("user",JSON.stringify(data.data));
                    $(document).dialog({
                        type : 'toast',
                        infoIcon: '/img/icon/success.png',
                        infoText: '登陆成功',
                        autoClose: 2500,
                    });
                    setTimeout(function () {
                        // 侧边栏登陆的时候,使用父窗口登陆
                        window.parent.location.href = '/index.html';
                    },1500);
                } else {
                    $(document).dialog({
                        autoClose: 2000,
                        content: data.msg,
                    });
                }
            });
        });
	</script>
</head>
<body>
<div class="container" >
	<h5>登录</h5>

	<div class="card card-container ">

		<img id="profile-img" class="fa fa-user-circle fa-5x profile-img imgHead" src="" width="60px"></img>

		<form class="form-signin" id="loginForm" action="/sessions" method="post">
			<input type="email"  name="email" value="dafei@wolfcode.cn" class="form-control badge-pill checkhead" placeholder="邮箱"  >
			<input type="password"  name="password" value="1" class="form-control badge-pill" placeholder="密码" >
			<a href="#" class="forgot-password">
				忘记密码？
			</a>
			<button class="btn btn-lg badge-pill" type="submit" >登录</button>
		</form>
	</div>


	<a href="register.html" class="registerLink" >
		新用户？点击这里注册
	</a>
</div>

</body>
</html>
